package jackson.src.day01;

import java.util.ArrayList;
import java.util.List;

/*
 * Author: JacksonCoder
 * FileName: refVariable
 * Version: 1.0.0
 */
public class refVariable {
    public static void main(String[] args) {
        System.out.println("this is ref knowLedge");

        valueReturn();
        refReturn();
    }

    public static void valueReturn(){
        List<String> names = new ArrayList<>();
        names.add("Alice");

        modifyList(names);
        System.out.println("After modifyList: " + names);
    }

    private static void modifyList(List<String> names) {
        names.add("wuSir");
    }

    public static void refReturn(){
        StringBuilder sb = new StringBuilder("hello");

        reassignReference(sb);
        System.out.println("After reassignReference: " + sb);
    }

    private static void reassignReference(StringBuilder builder) {
        builder = new StringBuilder("world");
    }
}
